package jwdt.xadmin;

import java.util.HashMap;
import java.util.Map;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.system.bean.TUser;

import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class IndexAction extends BaseAction {

	@RequestMapping("/listmenu")
	public Page doListmenu(Form f, Module m) throws Exception {
		TUser userInfo = (TUser)f.getSession("userInfo"); 
		String oskey = userInfo.getOskey();
		//一级菜单
		String sql1 = "SELECT a.cddm, a.cdmc,a.cdicon FROM jwdt_qx_cd a,jwdt_qx_jscd b WHERE a.CDDM=b.CDDM AND b.JSDM='"+oskey+"' AND a.zt=1 AND a.sjcd='' ORDER BY a.px";
		//二级菜单
		String sql2 = "SELECT a.cddm, a.cdmc,a.cdicon, a.sjcd, a.cdurl,a.cdicon FROM jwdt_qx_cd a,jwdt_qx_jscd b WHERE a.CDDM=b.CDDM AND b.JSDM='"+oskey+"' AND zt=1 AND sjcd!='' ORDER BY sjcd,px";
		//
		Map jsonObj = new HashMap();
		jsonObj.put("onemenu", jdb.query(sql1));
    	jsonObj.put("twomenu", jdb.query(sql2));
    	return m.jsonPage(f, jsonObj);
	}

	@RequestMapping("/news")
	public Page doNews(Form f, Module m) throws Exception {
		int typeid = f.getInt("typeid");
		String where = "";
		if(typeid != 0) {
			where = " where typeid=" + typeid;
		}
		f.add("news", jdb.query(super.select_news+where+super.order_news, 7));
		return m.findPage("/xadmin/news");
	}


}
